<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<style>
			html,
			body {
				height: 100%;
				margin: 0px;
				padding: 0px;
				background-color: #F8F8F8;
			}
			.mui-bar{
			background:##F8F8F8;
			}
			
		.mui-titles{
			position: relative;
			float: right;
		}
		.mui-content{
			position: relative;
			float: left;
			width: 100%;
			padding: 10px  15px;
			box-sizing: border-box;
			display: inline-block;
			background:#F8F8F8;
		}		
		
		.biaoti{
			position: relative;
			float: left;
			width: calc(100% - 44px);
			height: 100%;
			display: flex;
			justify-content: space-around;
			padding-top: 5px;
			box-sizing: border-box;
		}
		
		.biaoti>div{
			width: 64px;
			height: 35px;
			font-size:15px;
            font-weight:bold;
            color:rgba(51,51,51,1);
			line-height: 35px;
			box-sizing: border-box;
		}
	.tiactive{
			border-bottom: 2px  solid #FE615E;
			color: #FE615E!important;
	}
		
		.mui-bar-nav>img:nth-child(1){
			position: relative;
			float: left;
			width: 20px;
			height: 27px;
			margin-top: 10px;
		}
	
		a{
		color:rgba(51,51,51,1);
		}
		a:active{
				color:rgba(51,51,51,1);
		}
		.dan,.dans{
			position: relative;
			float: left;
			width: 100%;
			height: 232px;
			background: #FFFFFF;
			margin-top: 15px;
			padding: 0px 10px ;
			box-sizing: border-box;
		}
		
		.dantitle{
			position: relative;
			float: left;
            width: 100%;
			height: 43px;
			border-bottom: 1px  solid  rgba(248,248,248,1);
		}
		.dantitle>div:nth-child(1){
			position: relative;
			float: left;
			width: calc(100% - 90px);
			height:100%;
			font-size:14px;
            font-weight:500;
            color:rgba(51,51,51,1);
            line-height:43px;
		}
		
		.dantitle>div:nth-child(2){
			position: relative;
			float: right;
			width: 80px;
			height:100%;
			font-size:14px;
		    font-weight:500;
			text-align: right;
		    color:rgba(254,31,31,1);
		    line-height:43px;
		}
		.dancontent{
			position: relative;
			float: left;
			width: 100%;
			height: 130px;
			border-bottom: 1px  solid  rgba(248,248,248,1);
		}
		.dancontent>div:nth-child(1){
			position: relative;
			float: left;
			width: 114px;
			height: 100%;
			padding-top: 15px;
			box-sizing: border-box;
		}
		.dancontent>div:nth-child(1)>img{
			width: 114px;
			height: 98px;
		}
		
		.dancontent>div:nth-child(2){
			position: relative;
			float: right;
			width: calc(100% -  124px);
			height: 100%;
			padding:15px 0px;
			box-sizing: border-box;
		}
		
		.dancontent>div:nth-child(2)>div:nth-child(1){
			position: relative;
			float: right;
			width: 100%;
			height: 18px;
			font-size:14px;
            font-weight:500;
            color:rgba(51,51,51,1);
            line-height:18px;
			text-overflow: ellipsis;
			overflow: hidden;
		}
		
		.dancontent>div:nth-child(2)>div:nth-child(2){
			position: relative;
			float: left;
			width: 100%;
			height: 18px;
			line-height: 18px;
			margin-top: 10px;
		}
		
		.dancontent>div:nth-child(2)>div:nth-child(2)>span{
			position: relative;
			float: left;
			width: 50%;
			height: 18px;
			line-height: 18px;
			text-align: left;
			font-size: 12px;
		}
		.dancontent>div:nth-child(2)>div:nth-child(2)>span:last-child{
		
			text-align: right;
		}
		
		.dancontent>div:nth-child(2)>div:nth-child(3){
			position: relative;
			float: left;
			width: 100%;
			line-height: 18px;
			height: 18px;
			font-size: 12px;
		}
		
		
		
		.dancontent>div:nth-child(2)>div:nth-child(4){
			position: absolute;
			bottom: 15px;
			width: 100%;
			height: 18px;
		}
		
		.dancontent>div:nth-child(2)>div:nth-child(4)>div:nth-child(1){
			position: relative;
			float: left;
			width: 50%;
			height: 100%;
			font-size:16px;
            font-weight:bold;
            color:rgba(51,51,51,1);
            line-height:18px;
		}
		
			.dancontent>div:nth-child(2)>div:nth-child(2)>div:nth-child(2){
			position: relative;
			float: left;
			width: 50%;
			height: 100%;
			font-size:16px;
			text-align: right;
			color:rgba(51,51,51,1);
			line-height:18px;
		}
		
		.danqueren{
			position: relative;
			width: 100%;
			height: 58px;
            float: left; 			
		}
		.danqueren>div:nth-child(1){
			width: 65px;
			height: 28px;
			text-align: center;
			position: relative;
			float: left;
			margin-top: 15px;
			line-height: 28px;
			font-size:13px;
            font-weight:500;
            color:rgba(255,255,255,1); 
			background:rgba(254,97,94,1);
            border-radius:3px;
		}
			.danqueren>div:nth-child(2){
			width: 65px;
			height: 28px;
			text-align: center;
			position: relative;
			float: left;
			margin-top: 15px;
			line-height: 28px;
			font-size:13px;
		    font-weight:500;
		   color:rgba(153,153,153,1);
		    border-radius:3px;
			border:1px solid rgba(223,223,223,1);
             border-radius:3px;
			 margin-left: 8px;
		}
		
		.danqueren>div:nth-child(3){
					position: relative;
					float: right;
					width: calc(100% - 140px);
					height: 28px;
					margin-top: 15px;
				}
		.danqueren>div:nth-child(3)>span:nth-child(1){
			position: relative;
			float: right;
			padding: 0  5px;
			box-sizing: border-box;
			font-size:16px;
            font-weight:bold;
            color:rgba(254,31,31,1);
            line-height:28px;
		}
				.danqueren>div:nth-child(3)>span:nth-child(2){
					position: relative;
					float: right;
					padding: 0  5px;
					box-sizing: border-box;
					font-size:16px;
				color:rgba(51,51,51,1);
					line-height:28px;
				}
				
				
				
				
				
			/*  视频 */
				
				
				.danstitle{
					position: relative;
					float: left;
				    width: 100%;
					height: 43px;
					border-bottom: 1px  solid  rgba(248,248,248,1);
				}
				.danstitle>div:nth-child(1){
					position: relative;
					float: left;
					width: calc(100% - 90px);
					height:100%;
				}
				.danstitle>div:nth-child(1)>img{
					position: relative;
					float: left;
					width: 35px;
						border-radius: 50%;
					height: 35px;
					margin-top: 5px;
				}
					.danstitle>div:nth-child(1)>div{
					position: relative;
					float: left;
					width: 35px;
					height: 35px;
					margin-left: 10px;
					font-size:14px;
					font-weight:500;
					color:rgba(51,51,51,1);
					line-height:43px;
					 line-height:43px;
				}
				
				.danstitle>div:nth-child(2){
					position: relative;
					float: right;
					width: 80px;
					height:100%;
					font-size:14px;
				    font-weight:500;
					text-align: right;
				    color:rgba(254,31,31,1);
				    line-height:43px;
				}
				.danscontent{
					position: relative;
					float: left;
					width: 100%;
					height: 130px;
					border-bottom: 1px  solid  rgba(248,248,248,1);
				}
				.danscontent>div:nth-child(1){
					position: relative;
					float: left;
					width: 114px;
					height: 100%;
					padding-top: 15px;
					box-sizing: border-box;
				}
				.danscontent>div:nth-child(1)>img{
					width: 114px;
					height: 98px;
				
				}
				
				.danscontent>div:nth-child(2){
					position: relative;
					float: right;
					width: calc(100% -  124px);
					height: 100%;
					padding:15px 0px;
					box-sizing: border-box;
				}
				
				.danscontent>div:nth-child(2)>div:nth-child(1){
					position: relative;
					float: right;
					width: 100%;
					font-size:14px;
					height: 18px;
				    font-weight:500;
				    color:rgba(51,51,51,1);
				    text-overflow: ellipsis;
				    overflow: hidden;
				}
				.danscontent>div:nth-child(2)>div:nth-child(2){
					position: relative;
					float: right;
					width: 100%;
					font-size:12px;
				    font-weight:500;
				    color:rgba(51,51,51,1);
				    line-height:21px;
					margin-top: 10px;
				}
				 
				.danscontent>div:nth-child(2)>div:nth-child(3){
					position: relative;
					float: right;
					width: 100%;
					font-size:12px;
				    font-weight:500;
				    color:rgba(51,51,51,1);
				    line-height:21px;
				}
				 
				
				.danscontent>div:nth-child(2)>div:nth-child(4){
					position: absolute;
					bottom: 15px;
					width: 100%;
					height: 18px;
				}
				.danscontent>div:nth-child(2)>div:nth-child(4)>div:nth-child(1){
					position: relative;
					float: left;
					width: 50%;
					height: 100%;
					font-size:14px;
				    font-weight:bold;
				    color:rgba(51,51,51,1);
				    line-height:18px;
				}
				
					.danscontent>div:nth-child(2)>div:nth-child(4)>div:nth-child(2){
					position: relative;
					float: left;
					width: 50%;
					height: 100%;
					font-size:14px;
					text-align: right;
					color:rgba(51,51,51,1);
					line-height:18px;
				}
				
				.dansqueren{
					position: relative;
					width: 100%;
					height: 58px;
				    float: left; 			
				}
				.dansqueren>div:nth-child(1){
							position: relative;
							float: right;
							width: 100% ;
							height: 28px;
							margin-top: 15px;
						}
				.dansqueren>div:nth-child(1)>span:nth-child(1){
					position: relative;
					float: right;
					padding: 0  5px;
					box-sizing: border-box;
					font-size:16px;
				    font-weight:bold;
				    color:rgba(254,31,31,1);
				    line-height:28px;
				}
						.dansqueren>div:nth-child(1)>span:nth-child(2){
							position: relative;
							float: right;
							padding: 0  5px;
							box-sizing: border-box;
							font-size:16px;
						color:rgba(51,51,51,1);
							line-height:28px;
						}
						
				 #login{
					 
					 height: 50px!important;
					 line-height: 50px!important;
					 padding: 0 !important;
					 margin-top: 50px;
				 }
				
							
							.cancel{
								position: absolute;
								right: 20px;
								color: black;
								font-size: 16px;
								top: 12px;
							}
							.tanchuang{
								position: absolute;
								z-index: 100;
								width: 100%;
								height: 100%;
								background: rgba(1,1,1,0.6);
							}
							
							#login-form{
                                margin-top: 40px;								
							}
		</style>
	</head>

	<body contextmenu="return false;">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<div class="biaoti">
				<div class="tiactive" index="0">我的订单</div>
				<div index="1">销售订单</div>
			</div>
		</header>
		<div class="mui-content" id="content">
			<div class="danone">
			</div>


			<div class="dantwo" style="display: none;">

			</div>

		</div>

		<div class="tanchuang" style="display: none;">
			<header class="mui-bar mui-bar-nav">
				<h1 class="mui-title">填订单列表</h1>
				<div class="cancel">取消</div>
			</header>
			<div class="mui-content">
				<form id='login-form' class="mui-input-group">
					<div class="mui-input-row">
						<label>快递公司</label>
						<input id='kaidigongshi' type="text" class="mui-input-clear mui-input" placeholder="请输入快递公司">
					</div>
					<div class="mui-input-row">
						<label>快递单号</label>
						<input id='kuaididanhao' type="text" class="mui-input-clear mui-input" placeholder="请输入快递单号">
					</div>

				</form>
				<div class="mui-content-padded">
					<button id='login' class="mui-btn mui-btn-block mui-btn-red">确认</button>
				</div>
			</div>
			<div class="mui-content-padded oauth-area">

			</div>
		</div>

		</div>

	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" charset="utf-8">
		mui.plusReady(function() {
			var url = plus.storage.getItem('url');
			var user = plus.storage.getItem('user');
			user = JSON.parse(user);
			var jinpage = 1;
			var chupage = 1;
			var type = 0;

			mui.init({
				pullRefresh: {
					container: 'body', //待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
					up: {
						height: 50, //可选.默认50.触发上拉加载拖动距离
						auto: true, //可选,默认false.自动上拉加载一次
						contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
						contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
						callback: function() {
							var that = this;

							getData(function() {
								mui('body').pullRefresh().endPullupToRefresh();
							})

						}
					},
				}
			})



			function getData(myfunc) {
				var page = 1;
				if (type == 1) {
					page = jinpage;
				} else if (type == 2) {
					page = chupage;
				}
				if (page == 0) {
					mui.toast('没有更多数据了！');
					if (myfunc) {
						myfunc();
					}
					return;
				}
				plus.nativeUI.showWaiting();
				mui.post(url + '/juyou/myorder/getorder', {
					token: user.token,
					page: page,
					type: type
				}, function(res) {
					plus.nativeUI.closeWaiting();
					// mui.toast(res.msg)
					if (res.code == 200) {
						if (type == 0) {
							if (res.data.jin.length < 10) {
								jinpage = 0;
							} else {
								jinpage = 2;
							}
							if (res.data.chu.length < 10) {
								chupage = 0;
							} else {
								chupage = 2;
							}
							var str = '';
							mui.each(res.data.jin, function(i, v) {
								str += '<div   class="dans" >' +
									'<div class="danstitle">' +
									'<div><img  src="' + v.sell_user.touxiang + '" /> <div>' + v.sell_user.name + '</div></div>';

								str += '<div>' + v.commodity_status + '</div>';
								str += '</div>' +
									'<div class="danscontent">' +
									'<div><img  src="' + v.commodity.tupian + '" /></div>' +
									'<div> ' +
									'<div>' + v.commodity.name + '</div>';
								if (v.express && v.express_order) {
									str += '<div>' + v.express  +'</div><div>' + v.express_order + '</div>';
									
								} else {
									str += '<div></div><div></div>';
								}


								str += '<div>' +
									'<div> 金币：' + v.commodity.icons + '</div>' +
									'<div>x' + v.number + '</div>' +
									'</div>' +
									'</div>' +
									'</div>' +
									'<div class="danqueren">' ;
									if(v.commodity_status=='退货中'){
										str+='<div class="" style="display:none" data-phyid="'+v.id+'">确认收货</div>' ;
									}else if(v.commodity_status=='已完成'){
										str+='<div class="pingjia"  data-phyid="'+v.id+'">评价</div>' ;
									}else{
										str+='<div class="shouhuo" data-phyid="'+v.id+'">确认收货</div>' ;
									}
									
									if(v.commodity_status=='申请退货'){
										str+='<div class="shengqingtuihuo"  data-phyid="'+v.id+'">等待确认</div>' ;
									}else if(v.commodity_status=='拒绝退货'){
										str+='<div class="shengqingtuihuo"  data-phyid="'+v.id+'">申请退货</div>';
									}else if(v.commodity_status=='退货中'){
										str+='<div class="huoqudizhi"  data-phyid="'+v.id+'">获取地址</div>';
									}else if(v.commodity_status=='已完成'){
										str+='<div class="shengqingtuihuo" style="display:none"  data-phyid="'+v.id+'">申请退货</div>';
									}else{
										str+='<div class="shengqingtuihuo"  data-phyid="'+v.id+'">申请退货</div>';
									}
									str+='<div><span>' + parseFloat(v.commodity.icons) * parseInt(v.number) + '</span><span>总计：</span></div>' +
									'</div>	' +
									'</div> ';
							})
							
							
							
							
							$(".danone").append(str);
							str = '';
							mui.each(res.data.chu, function(i, v) {
								str += '<div   class="dan">' +
									'<div class="dantitle">';
								if (v.express!==' '&& v.express_order!==' ') {
									str += '<div>' + v.express + ':' + v.express_order + '</div>';
								} else {
									str += '<div></div>';
								}

								str += '<div>' + v.commodity_status + '</div> ' +
									'</div>' +
									'<div class="dancontent">' +
									'<div>' +
									'<img src="' + v.commodity.tupian + '" />' +
									'</div>' +

									'<div>' +
									'<div>' + v.commodity.name + '</div>' +
									'<div><span>'+v.sell_name+'</span><span>'+v.sell_phone+'</span></div>' +
									'<div>'+v.sell_address+'</div>' +
									'<div>' +
									'<div>金币:' + v.commodity.icons + '</div>' +
									'<div>x' + v.number + '</div>' +
									'</div>' +
									'</div>' +
									'</div>' +
									'<div class="danqueren">' ;
									if(v.commodity_status=='待发货'){
										str+='<div class="fahuo" data-phyid="'+v.id+'">确认发货</div>';
									}else{
										str+='<div class="fahuo" style="display:none" data-phyid="'+v.id+'">确认发货</div>';
									}
									if(v.commodity_status=='申请退货'){
										str+='<div class="soulituihuo" data-phyid="'+v.id+'">受理退货</div>';
									}else if(v.commodity_status=='退货中'){
										str+='<div  class="qurendaohuo" data-phyid="'+v.id+'">确认到货</div>';
									}else{
										str+='<div  class="soulituihuo" style="display:none" data-phyid="'+v.id+'">受理退货</div>';
									}
									str+='<div><span>' + parseFloat(v.commodity.icons) * parseInt(v.number) + '</span><span>总计：</span></div>' +
									'</div>' +
									'</div>';
							})
							$(".dantwo").append(str)
							type = 1;
						} else if (type == 1) {
							var str = '';
							mui.each(res.data, function(i, v) {
								str += '<div   class="dans" >' +
									'<div class="danstitle">' +
									'<div><img  src="' + v.sell_user.touxiang + '" /> <div>' + v.sell_user.name + '</div></div>';

								str += '<div>' + v.commodity_status + '</div>';
								str += '</div>' +
									'<div class="danscontent">' +
									'<div><img  src="' + v.commodity.tupian + '" /></div>' +
									'<div> ' +
									'<div>' + v.commodity.name + '</div>';
								if (v.express && v.express_order) {
									str += '<div>' + v.express  +'</div><div>' + v.express_order + '</div>';
									
								} else {
									str += '<div></div><div></div>';
								}


								str += '<div>' +
									'<div> 金币：' + v.commodity.icons + '</div>' +
									'<div>x' + v.number + '</div>' +
									'</div>' +
									'</div>' +

									'</div>' +
									'<div class="danqueren">' ;
									if(v.commodity_status=='退货中'){
										str+='<div class="" style="display:none" data-phyid="'+v.id+'">确认收货</div>' ;
									}else if(v.commodity_status=='已完成'){
										str+='<div class="pingjia"  data-phyid="'+v.id+'">评价</div>' ;
									}else{
										str+='<div class="shouhuo" data-phyid="'+v.id+'">确认收货</div>' ;
									}
									if(v.commodity_status=='申请退货'){
										str+='<div class="shengqingtuihuo"  data-phyid="'+v.id+'">等待确认</div>' ;
									}else if(v.commodity_status=='拒绝退货'){
										str+='<div class="shengqingtuihuo"  data-phyid="'+v.id+'">申请退货</div>';
									}else if(v.commodity_status=='退货中'){
										str+='<div class="huoqudizhi"  data-phyid="'+v.id+'">获取地址</div>';
									}else if(v.commodity_status=='已完成'){
										str+='<div class="shengqingtuihuo" style="display:none"  data-phyid="'+v.id+'">申请退货</div>';
									}else{
										str+='<div class="shengqingtuihuo"  data-phyid="'+v.id+'">申请退货</div>';
									}
									str+='<div><span>' + parseFloat(v.commodity.icons) * parseInt(v.number) + '</span><span>总计：</span></div>' +
									'</div>	' +
									'</div> ';
							})
							$(".danone").append(str);
						} else if (type == 2) {
							var str = '';
							mui.each(res.data, function(i, v) {
								str += '<div   class="dan">' +
									'<div class="dantitle">';
								if (v.express!==' '&& v.express_order!==' ') {
									str += '<div>' + v.express + ':' + v.v.express_order + '</div>';
								} else {
									str += '<div></div>';
								}

								str += '<div>' + v.commodity_status + '</div> ' +
									'</div>' +
									'<div class="dancontent">' +
									'<div>' +
									'<img src="' + v.commodity.tupian + '" />' +
									'</div>' +

									'<div>' +
									'<div>' + v.commodity.name + '</div>' +
									'<div><span>'+v.sell_name+'</span><span>'+v.sell_phone+'</span></div>' +
									'<div>'+v.sell_address+'</div>' +
									'<div>' +
									'<div>金币:' + v.commodity.icons + '</div>' +
									'<div>x' + v.number + '</div>' +
									'</div>' +
									'</div>' +
									'</div>' +
									'<div class="danqueren">' ;
									if(v.commodity_status=='待发货'){
										str+='<div class="fahuo" data-phyid="'+v.id+'">确认发货</div>';
									}else{
										str+='<div class="fahuo" style="display:none" data-phyid="'+v.id+'">确认发货</div>';
									}
									if(v.commodity_status=='申请退货'){
										str+='<div class="soulituihuo" data-phyid="'+v.id+'">受理退货</div>';
									}else if(v.commodity_status=='退货中'){
										str+='<div  class="qurendaohuo" data-phyid="'+v.id+'">确认到货</div>';
									}else{
										str+='<div  class="soulituihuo" style="display:none" data-phyid="'+v.id+'">受理退货</div>';
									}
									str+='<div><span>' + parseFloat(v.commodity.icons) * parseInt(v.number) + '</span><span>总计：</span></div>' +
									'</div>' +
									'</div>';
							})
							$(".dantwo").append(str)
						}
					} else {
						mui.toast(res.msg);
					}
					if (myfunc) {
						myfunc();
					}
				})
			}


			var height = $(window).height();
			$("body").css("height", height);
			//订单切换
			mui(".biaoti").on("tap", "div", function() {
				var state = $(this).addClass("tiactive")
				$(this).siblings().removeClass("tiactive");
				var value = $(this).attr("index");
				// console.log(value)
				if (value == 0) {
					type = 1;
					$(".dantwo").css("display", "none");
					$(".danone").css("display", "block");
				} else if (value == 1) {
					type = 2;
					$(".danone").css("display", "none");
					$(".dantwo").css("display", "block");
				}
			})




		// 点击确认发货
				mui(document).on("tap", ".fahuo", function() {
					var phyid = $(this).attr('data-phyid');
					var that = this;
					
					// mui.alert(phyid)
					$(".tanchuang").show();
						$(window).scrollTop(0)
					$("body").on("touchmove", function(e) {
						e.preventDefault(); //取消一个事件的默认行为
					}, false)
						// 点击确认
						mui(document).on("tap", "#login", function() {
							// mui.alert(phyid);
						var  express=$("#kaidigongshi").val();
						var  express_order=$("#kuaididanhao").val();
						// mui.alert(url);return
						mui.post(url+'/juyou/myorder/querenfahuo',{token:user.token,express:express,express_order:express_order,id:phyid},function(res){
							mui.toast(res.msg);
							if(res.code==200){
								$(that).parents('.dan').children('.dantitle').children('div').eq(0).text(res.data.express+':'+res.data.express_order);
								$(that).parents('.dan').children('.dantitle').children('div').eq(1).text(res.data.commodity_status);
								$(that).parents('.dan').find('.fahuo').hide();
							}else{
								mui.toast(res.msg);
							}
							$(".tanchuang").hide();
							$("body").off("touchmove");
						})
							
						})
						// 点击取消
						mui(document).on("tap", ".cancel", function() {
							$(".tanchuang").hide();
							$("body").off("touchmove");
						})
				})
				//申请退货
				mui(document).on('tap','.shengqingtuihuo',function(){
					var phyid = $(this).attr('data-phyid');
					var that = this;
					mui.confirm('你确定要退货吗?退货由你承担运费哦！','提示',['取消','确定'],function(e){
						if(e.index==1){
							mui.post(url+'/juyou/myorder/shenqingtuihuo',{token:user.token,id:phyid},function(res){
								if(res.code==200){
									mui.toast(res.msg);
									$(that).parents('.dan').children('.dantitle').children('div').eq(1).text(res.data.commodity_status);
									$(that).text('等待确认');
								}else{
									mui.toast(res.msg);
								}
							})
						}
					})
					// mui.alert(phyid)
				})
				//受理退货
				mui(document).on('tap','.soulituihuo',function(){
					var phyid = $(this).attr('data-phyid');
					var that = this;
					mui.confirm('是否确定受理退货！','提示',['拒绝','受理'],function(e){
						if(e.index==1){
							mui.post(url+'/juyou/myorder/soulituihuo',{token:user.token,id:phyid,commodity_status:1},function(res){
								if(res.code==200){
									mui.toast(res.msg);
									$(that).parents('.dan').children('.dantitle').children('div').eq(1).text(res.data.commodity_status);
									$(that).removeClass('soulituihuo');
									$(that).addClass('qurendaohuo');
									$(that).text('确认到货');
								}else{
									mui.toast(res.msg);
								}
								return
							})
						}else{
							mui.post(url+'/juyou/myorder/soulituihuo',{token:user.token,id:phyid,commodity_status:2},function(res){
								if(res.code==200){
									mui.toast(res.msg);
									$(that).parents('.dan').children('.dantitle').children('div').eq(1).text(res.data.commodity_status);
									$(that).hide();
								}else{
									mui.toast(res.msg);
								}
								return
							})
						}
					})
				})
				//获取地址
				mui(document).on('tap','.huoqudizhi',function(){
					var phyid = $(this).attr('data-phyid');
					var that = this;
					mui.post(url+'/juyou/myorder/getdizhi',{token:user.token,id:phyid},function(res){
						if(res.code==200){
							// mui.confirm('店家姓名:'+res.data.name+'<br>手机号码:'+res.data.phone+'<br>'+'退货地址:'+res.data.address,'提示',['取消','确定'],function(){
							// 	
							// })
							// 
							    var btnArray = ['确认', '取消'];
							    var tuihuo=res.data.name+":"+res.data.phone;
								var dizhi="退货地址："+res.data.address
							    mui.confirm(dizhi, tuihuo, btnArray, function(e) { 
							        if (e.index == 0) { 
							            plus.device.dial(Phone, false); 
							        }  
							    })
			
						}else{
							mui.toast(res.msg);
						}
					})
				})
				
				//已收货
				mui(document).on('tap','.shouhuo',function(x){
					var phyid = $(this).attr('data-phyid');
					var that = this;
					mui.confirm('你确定已收货了吗？','提示',['取消','确定'],function(e){
						if(e.index==1){
							mui.post(url+'/juyou/myorder/querensouhuo',{token:user.token,id:phyid},function(res){
								if(res.code==200){
									mui.toast(res.msg);
									// mui.alert($(that).parents('.dan').children('.dantitle').children('div').eq(1).text());
									$(that).parents('.dans').children('.danstitle').children('div').eq(1).text('已完成');
									$(that).next().hide();
									$(that).text('评价');
									$(that).removeClass('shouhuo');
									$(that).addClass('pingjia');
									x.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
									var btnArray = ['取消', '确定'];
									mui.prompt('请输入你对这个商品的评价：', '例如商品质量好等等', '你好', btnArray, function(z) {
										if (z.index == 1) {
											var str = z.value;
											if(!str){
												mui.toast('你没有输入任何东西');
												return
											}
											mui.post(url+'/juyou/myorder/pingjiashangping',{token:user.token,str:str,id:phyid},function(ress){
												if(ress.code==200){
													mui.toast(ress.msg);
												}else{
													mui.toast(ress.msg);
												}
											})
										} else {
											// '你点了取消按钮';
										}
									})
								}else{
									mui.toast(res.msg);
								}
							})
						}
					})
				})
				//确认到货
				mui(document).on('tap','.qurendaohuo',function(){
					var phyid = $(this).attr('data-phyid');
					var that = this;
					// mui.alert(phyid);
					mui.confirm('你确定已收到货了吗？','提示',['取消','确定'],function(e){
						if(e.index==1){
							mui.post(url+'/juyou/myorder/querendaohuo',{token:user.token,id:phyid},function(res){
								if(res.code==200){
									mui.toast(res.msg);
									$(that).parents('.dan').children('.dantitle').children('div').eq(1).text(res.data.commodity_status);
									$(that).hide();
								}else{
									mui.toast(res.msg);
								}
							})
						}
					})
				})
				//评论商品
				mui(document).on('tap','.pingjia',function(e){
					var phyid = $(this).attr('data-phyid');
					var that = this;
					e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
					var btnArray = ['取消', '确定'];
					mui.prompt('请输入你对这个商品的评价：', '例如商品质量好等等', '你好', btnArray, function(z) {
						if (z.index == 1) {
							var str = z.value;
							if(!str){
								mui.toast('你没有输入任何东西');
								return
							}
							mui.post(url+'/juyou/myorder/pingjiashangping',{token:user.token,str:str,id:phyid},function(ress){
								if(ress.code==200){
									mui.toast(ress.msg);
								}else{
									mui.toast(ress.msg);
								}
							})
						} else {
							// '你点了取消按钮';
						}
					})
				})
				
		})

		//点击图片跳转聊天
		mui(document).on("tap", ".liaot_img", function() {
			mui.openWindow({
				url: 'liaotian.html',
				id: 'liaotian.html'
			})
		})
		
		// 点击取消
		mui(document).on("tap", ".cancel", function() {
			$(".tanchuang").hide();
			$("body").off("touchmove");
		})


		// // 点击确认
		// mui(document).on("tap", "#login", function() {
		// var  name=$("").val();
		// var  wuliuhao=$("").val();
		// 	$(".tanchuang").hide();
  //           $("body").off("touchmove");
		// })
		
		//点击确认收货 弹出是否去评价
			document.getElementById("promptBtn").addEventListener('tap', function(e) {
			e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug，使用plus.nativeUI.prompt会造成输入法闪一下又没了
			var btnArray = ['取消', '确定'];
			mui.prompt('请输入你对这个商品的评价：', '例如商品质量好等等', '你好', btnArray, function(e) {
				if (e.index == 1) {
					// info.innerText = '谢谢你的评语：' + e.value;
				} else {
					// '你点了取消按钮';
				}
			})
		});
		
		
	</script>


</html>
